<!--
  文件描述：无缝滚动组件
-->
<template>
  <div class="emergency_box">
    <div class="emergency_top">
      <div class="emergency_title">客户应收明细</div>
    </div>

    <div class="echarts_container">
      <div class="header" style="background:rgba(107, 189, 255, 0.2)">
        <div class="flex_item">客户名称</div>
        <div class="flex_item">含税总金额</div>
        <div class="flex_item">已开票金额</div>
        <div class="flex_item">未开票金额</div>
        <div class="flex_item">已收款金额</div>
        <div class="flex_item">未收款金额</div>
        <div class="flex_item">附加收款金额</div>
        <div class="flex_item">附加已收金额</div>
        <div class="flex_item">累计收款金额</div>
        <div class="flex_item">累计已收金额</div>
        <div class="flex_item">未收金额</div>

      </div>
      <div v-if="tableData&&tableData.length>0" class="page-example3">
        <vue-seamless-scroll :data="tableData" :class-option="defaultOption" @ScrollEnd="ScrollEnd">
          <div v-for="(item,index) in tableData" :key="index" class="header header_line">
            <div class="flex_item item_color">{{ item.customerName }}</div>
            <div class="flex_item item_color">{{ item.taxAllPrice }}</div>
            <div class="flex_item item_color">{{ item.hasReceiptPrice }}</div>
            <div class="flex_item item_color">{{ item.unReceiptPrice }}</div>
            <div class="flex_item item_color">{{ item.hasPrice }}</div>
            <div class="flex_item item_color">{{ item.unPrice }}</div>
            <div class="flex_item item_color">{{ item.otherPrice }}</div>
            <div class="flex_item item_color">{{ item.hasOtherPrice }}</div>
            <div class="flex_item item_color">{{ item.totalPrice }}</div>
            <div class="flex_item item_color">{{ item.totalHasPrice }}</div>
            <div class="flex_item item_color">{{ item.totalUnPrice }}</div>
          </div>
        </vue-seamless-scroll>
      </div>
      <div v-else class="echarts_noData">
        <svg-icon icon-class="暂无数据" />
      </div>
      <div class="header">
        <div class="flex_item">合计</div>
        <div class="flex_item">{{ total.bottomTaxAllPrice }}</div>
        <div class="flex_item">{{ total.bottomHasReceiptPrice }}</div>
        <div class="flex_item">{{ total.bottomUnReceiptPrice }}</div>
        <div class="flex_item">{{ total.bottomHasPrice }}</div>
        <div class="flex_item">{{ total.bottomUnPrice }}</div>
        <div class="flex_item">{{ total.bottomOtherPrice }}</div>
        <div class="flex_item">{{ total.bottomHasOtherPrice }}</div>
        <div class="flex_item">{{ total.bottomTotalPrice }}</div>
        <div class="flex_item">{{ total.bottomTotalHasPrice }}</div>
        <div class="flex_item">{{ total.bottomTotalUnPrice }}</div>
      </div>
    </div>

  </div>
</template>

<script>
import { list as alarm } from '@/api/receivableAndPayable/receivableAndPayableManage/receiptSummarizing.js'
import vueSeamlessScroll from 'vue-seamless-scroll'
export default {
  components: {
    vueSeamlessScroll
  },
  data() {
    // 这里存放数据
    return {
      tableData: [],
      timer: undefined,
      total: {
        bottomHasOtherPrice: '',
        bottomHasPrice: '',
        bottomHasReceiptPrice: '',
        bottomOtherPrice: '',
        bottomTaxAllPrice: '',
        bottomTotalHasPrice: '',
        bottomTotalPrice: '',
        bottomTotalUnPrice: '',
        bottomUnPrice: '',
        bottomUnReceiptPrice: ''
      }
    }
  },
  // 监听属性 类似于data概念
  computed: {
    defaultOption() {
      return {
        step: 0.3,
        limitMoveNum: 6, // 开始无缝滚动的数据量
        hoverStop: true, // 是否开启鼠标悬停stop
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 180, // 单步运动停止的高度(默认值0是无缝不停止的滚动)
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
      }
    }
  },
  // 监控data中的数据变化
  watch: {
    tableData(newValue, oldValue) {
      // if (newValue.length < 6) {
      //   clearInterval(this.timer)
      //   this.timer = setInterval(() => {
      //     this.getAlarm()
      //   }, this.$store.state.common.refreshFrequency * 1000)
      // } else {
      //   clearInterval(this.timer)
      // }
    }
  },
  beforeDestroy() {
    // 页面关闭清除定时器
    clearInterval(this.timer)
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.getAlarm()
    this.timer = setInterval(() => {
      this.getAlarm()
    }, this.$store.state.common.refreshFrequency * 1000)
  },
  // 方法集合
  methods: {
    ScrollEnd() {
      // this.getRepairingDetails()
    },
    getAlarm() {
      alarm({ companyId: this.$store.state.user.companyId }).then(res => {
        this.tableData = res.data.data
        Object.keys(this.total).forEach(key => {
          this.total[key] = res[key]
        })
      })
    }
  }
}
</script>

<style scoped lang="scss">
.emergency_box{
  width: 100%;
  height: calc(100% - 50px);
}
.emergency_top{
  display: flex;
  justify-content: space-between;
  z-index: 99999;
  .emergency_title{
    font-size: 20px;
    line-height: 34px;
    font-weight: bold;
    letter-spacing: -0.21px;
    color: #333333;
    padding-top: 16px;
    padding-left: 20px;
    width: 100%;
  }
  .emergency_month{
    display: flex;
    font-size: 18px;
    font-weight: normal;
    line-height: 25px;
    letter-spacing: -0.16px;
    color: #999999;
    padding-top: 22px;
    padding-right: 20px;
    cursor: pointer;
    .emergency_ThisMarch1{
      font-size: 18px;
      font-weight: normal;
      line-height: 25px;
      letter-spacing: -0.16px;
      color: #387BFC;
      padding-right: 30px;
    }
    .emergency_ThisMarch2{
      font-size: 18px;
      font-weight: normal;
      line-height: 25px;
      letter-spacing: -0.16px;
      color: #387BFC;
    }
    .emergency_March{
      padding-right: 30px;
    }
    .emergency_LastMarch{
      padding-right: 30px;
    }
  }
}

.echarts_container{
  width: 100%;
  height: 100%;
  padding:10px 20px;
  .header{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding:4px 0 ;
    border-bottom: 1px solid #15AFCD;
    .flex_item{
      flex: 1;
      text-align: center;
    }
    .flex_item2{
      text-align: center;
      flex: 2;
    }
    .item_color{
      color: rgba(102, 102, 102, 1);
      font-size: 15px;
    }
  }
  .header_line{
    border-bottom: 0.5px solid rgba(153, 153, 153, 0.2);
  }
}
.page-example3{
  width: 100%;
  height: 253px;
  overflow: hidden;
}
.page-example4 {
  display: flex;
}
</style>
